/*
 * @Description: 
 * @Author: fhw
 * @Date: 2022-12-26 13:54:57
 */
import { Injectable } from '@nestjs/common';
import { OssService } from 'src/modules/oss/oss.service';
import { throwHttp } from 'src/utlis';

@Injectable()
export class UploadService {
  constructor(private readonly ossService: OssService) { }
  // 上传照片
  async uploadImage(file: any): Promise<any> {
    try {
      const ossUrl = await this.ossService.putOssFile(`/image/${file.originalname}`, file.path)
      return {
        filename: file.originalname,
        url: ossUrl,
      }
    } catch (error) {
      throwHttp(error.message)
    }
  }
}